@extends('admin.main_table')
@section('title', '管理员管理')

@section('css')
    <link href="{{ asset('/static/css/admin/admin.css') }}" rel="stylesheet">
    <style>
        .pagination-detail{
            margin-left:20px;
        }
        .pagination{
            margin-right:20px;
        }
    </style>
@endsection

@section('content')
    <div class="col-md-12 main_body">
        <div style="margin-bottom:10px;">
            <button class="btn btn-default" type="button" id="add"><img src="{{ asset('/static/img/新增.png') }}" style="width:18px;height:18px;"/>&nbsp;新增</button>
            <button class="btn btn-default" type="button" id="delete"><img src="{{ asset('/static/img/删除.png') }}" style="width:18px;height:18px;"/>&nbsp;删除</button>
            <button class="btn btn-default" type="button" id="change"><img src="{{ asset('/static/img/修改.png') }}" style="width:18px;height:18px;"/>&nbsp;修改</button>
        </div>

        <table data-toggle="table" id="article_table"></table>
    </div>
@endsection

@section('script')
    <script>

        function initTable(){
            var $table = $('#article_table');
            $table.bootstrapTable({
                pagination: true, //分页
                url: '/admin/getAllUser',
                columns: [{
                    checkbox: true
                },{
                    field: 'id',
                    title: '用户id'
                }, {
                    field: 'name',
                    title: '用户名'
                }, {
                    field: 'created_at',
                    title: '创建时间'
                }]
            });
        }
        initTable();

        /*$("#add").click(function(){
            window.location="/addUser";
        });*/
        $('#delete').click(function () {
            var row=$('#article_table').bootstrapTable('getSelections');
            $.post('/deleteUser',{'row':row},function(data){
                window.location="/userManage";
            })
        });
        /*$("#change").click(function(){
            var row=$('#article_table').bootstrapTable('getSelections');
            var id=row[0].id;
            //alert(id)
            //console.log(id);
            window.location="/updateUser?id="+id;
        });*/
    </script>

@endsection